#!/usr/bin/env python

import sys
import time

def main():
    maps4Pv = {}
    
    for line in sys.stdin:
        try:
            s = line.strip().split('::')
            page = s[0]
            
            if not maps4Pv.has_key(page):
                maps4Pv[page] = 1
            else:
                maps4Pv[page] = maps4Pv[page] + 1

        except Exception,ex:
            print >> sys.stderr, ex
            continue
    
    lst = sorted(maps4Pv.items(), lambda x, y: cmp(x[1], y[1]), reverse=True) 
    pvsum = 0
    for k in lst:
        if k[1] == 1: continue #just ignore page whose visit count is less than 2
        pvsum = pvsum + k[1]
        print('%-06d %s'%(4*k[1], k[0]))
    print('pv sum:%d'%(4*pvsum))

if __name__ == "__main__":
    main()